/*
 * MassWriter.java
 *
 * Created on 26 aprile 2007, 13.32
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package alecava;

import alecava.interfacce.Progressable;
import java.io.IOException;

/**
 *
 * @author alecava
 */
public class MassWriter extends Thread{
    private AbstractCavaID3[] c;
    private String[][] fields;
    private Progressable p;
    /** fields deve avere dimensione [c.length][7] e i campi devono essere in ordine:
     artista, titolo, album, commento, anno, genere, traccia*/
    public MassWriter(AbstractCavaID3[] c, String[][] fields, Progressable p) {
        this.c = c;
        this.fields = fields;
        this.p = p;
    }
    
@Override
public void run(){
        p.start();
        p.setMax(c.length);
        /*effettua la scrittura*/
        for (int i = 0; i < c.length; i++){
            try {
                c[i].writeTag(fields[i][0], fields[i][1], fields[i][2], fields[i][3], fields[i][4], fields[i][5], fields[i][6]);
                p.setPosition(i);
            } catch (IOException ex) {
                ex.printStackTrace();
            } catch (NullPointerException ex) {
                ex.printStackTrace();
            }
        }
        p.finish();
    }
    
}
